<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="./index.js"></script>
    <script>
        var pr = new MyPromise(function (res, rej) {
            setTimeout(function () {
                var num = Math.random()
                if (num > 0.5) {
                    res('aaaa')
                } else {
                    rej('bbb')
                }
            }, 500)
        });
        pr.then(function (data) {
            console.log(data)
            return data
        }, function (err) {
            console.log(err)
            return new MyPromise(function(res, rej) {
                return rej('wokao')
            });
        }).then().then(function (data) {
            console.log(data, 'ok')
        }, function (err) {
            console.log(err, 'err')
        })

        var pro = new Promise(function (res, rej) {
            setTimeout(function () {
                var num = Math.random()
                if (num > 0.5) {
                    res('aaaa')
                } else {
                    rej('bbb')
                }
            }, 500)
        });
        pro.then(function (data) {
            console.log(data)
            return data
        }, function (err) {
            console.log(err)
            return new Promise(function(res, rej) {
                return rej('wokao')
            });
        }).then().then(function (data) {
            console.log(data, 'ok')
        }, function (err) {
            console.log(err, 'err')
        })
    </script>
</body>

</html>